package pop6;

public class Board {
	Ball[][] ballArray = new Ball[6][6];
	public Board(){
		for(int i=0;i<6;i++){
			for(int j=0;j<6;j++){
				ballArray[i][j]=null;
			}
			
		}
	}
	public void init(){
		for(int i=0; i<6; i++){
			Ball ball = new Ball(0,i,'0');
			this.placeBall(ball);
		}
		Ball ball = new Ball(1,0,'0');
		this.placeBall(ball);
	}
	public void display(){
		for(int i = 0 ; i<8;i++){
			System.out.print("*");
		}
		System.out.println("");
		for(int i = 0; i<6 ;i++){
			System.out.print("*");
			for(int j = 0; j<6;j++){
				if(ballArray[i][j]!=null)
					System.out.print(ballArray[i][j].getType());
				else
					System.out.print(" ");
			}
			System.out.print("*");
			System.out.println("");
		}
		for(int i = 0 ; i<8;i++){
			System.out.print("*");
		}
		System.out.println("");
	}
	
	public void clearBall(Ball ball){
		ballArray[ball.getRow()][ball.getCol()]=null;
	}
	public void clearBallsAfter(Ball ball){
		if(ball.getType()=='3'){
			this.clearBall(ball);
		}
			
	}
	public Ball getNextBall(char c){
		Ball ball1 = new Ball(5,2,c);
		this.placeBall(ball1);
		return ball1;
	}
	public void placeBall(Ball ball){
		ballArray[ball.getRow()][ball.getCol()]=ball;
	}
		
	/*public static void main(String args[]){
		Board board = new Board();
	
		for(int i=0; i<6; i++){
			Ball ball = new Ball(0,i,'0');
			board.placeBall(ball);
		}
		Ball ball = new Ball(1,0,'0');
		board.placeBall(ball);
		board.display();
		Ball ball1 = new Ball(5,2,'0');
		board.placeBall(ball1);
		board.display();
		board.clearBall(ball1);
		ball1.setCol(0);
		ball1.setRow(2);
		board.placeBall(ball1);
		board.display();
		board.clearBallsAfter(ball1);
		board.display();
	};
	*/
}
